package com.example.xm.servive.impl;

import com.example.xm.Entity.Pl;
import com.example.xm.config.PageResult;
import com.example.xm.mapper.PlMapper;
import com.example.xm.servive.PlServive;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PlServiveImpl implements PlServive {
    @Autowired
    PlMapper plMapper;

    @Override
    public List<Pl> getAllPl(Pl pl) {
        return plMapper.getAllPl(pl);
    }

    /**
     * 分页
     * */
    @Override
    public PageResult selectPager(int pageNum, int pageSize, Pl pl) {
        //开始分页，指定页码与每页记录数
        PageHelper.startPage(pageNum,pageSize);
        //执行查询，请求会被分页插件拦截
        List<Pl> students = plMapper.getAllPl(pl);
        //返回分页对象与数据
        return PageResult.getPageResult(new PageInfo<Pl>(students));
    }

    @Override
    public int AddPl(Pl pl) {
        return plMapper.AddPl(pl);
    }
}
